package com.ruoyi.train.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.train.domain.JyTrainingSchoolUser;
import com.ruoyi.train.mapper.JyTrainingSchoolUserMapper;
import com.ruoyi.train.service.IJyTrainingSchoolUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.Validator;
import java.util.List;

/**
 * 用户 业务层处理
 *
 * @author ruoyi
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class JyTrainingSchoolUserServiceImpl implements IJyTrainingSchoolUserService {
    private final JyTrainingSchoolUserMapper jyTrainingSchoolUserMapper;

    @Autowired
    protected Validator validator;

    /**
     * 根据条件分页查询用户列表
     *
     * @param user 用户信息
     * @return 用户信息集合信息
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<JyTrainingSchoolUser> selectUserList(JyTrainingSchoolUser user) {
        return jyTrainingSchoolUserMapper.selectUserList(user);
    }

    /**
     * 通过用户ID查询用户
     *
     * @param userId 用户ID
     * @return 用户对象信息
     */
    @Override
    public JyTrainingSchoolUser selectUserById(Long userId) {
        return jyTrainingSchoolUserMapper.selectUserById(userId);
    }

    /**
     * 修改保存用户信息
     *
     * @param user 用户信息
     * @return 结果
     */
    @Override
    @Transactional
    public int updateUser(JyTrainingSchoolUser user) {
        return jyTrainingSchoolUserMapper.updateUser(user);
    }

    /**
     * 修改用户状态
     *
     * @param user 用户信息
     * @return 结果
     */
    @Override
    public int updateUserStatus(JyTrainingSchoolUser user) {
        return jyTrainingSchoolUserMapper.updateUser(user);
    }

    /**
     * 重置用户密码
     *
     * @param user 用户信息
     * @return 结果
     */
    @Override
    public int resetPwd(JyTrainingSchoolUser user) {
        return jyTrainingSchoolUserMapper.updateUser(user);
    }
}
